package problems.daily;

/**
 * 2575. 找出字符串的可整除数组
 *
 * @author habitplus
 * @version: 1.0
 * @history: create by guan at 2024/3/7 21:14
 */
public class DT2575 {
    public int[] divisibilityArray(String word, int m) {
        if (word == null || word.length() < 1) {
            return new int[0];
        }
        int n = word.length();
        char[] chs = word.toCharArray();
        int[] ans = new int[n];
        long pre = 0;

        for (int i = 0; i < n; ++i) {
            pre = (pre * 10 + chs[i] - '0') % m;
            ans[i] = pre == 0 ? 1 : 0;
        }

        return ans;
    }
}
